<!--------------------------------------------------------------
>//	Company:	HTHK
>//	NAME:	    WeeklyExceptionExport.jsp
>//	TITLE:	    Weekly Exception Report of Staff
>//	FUNCTION:   Weekly Exception Report in any time range
>//	BY:	        Mike Cheng
>//	DATE:	    8/4/2003
>// --------------------------------------------------------------
-->
<!--------------------------------------------------------------
  Amend record
  Date          Version         Author          Description
  06/07/2004    1.0             Beyes           For log 1304.
---------------------------------------------------------------->

<%@ include file="../tssheader.jsp" %>
<%@ page import="tss.staffabsencereport.*" %>
<%@ page import="tss.options.*" %>

<!--Added by Mike. 2004-01-13. -->
<SCRIPT Language="Javascript" SRC="<%=contextPath%>/tss/staffabsencereport/Calendar1-821.js"></script>

<%
   	try
	{
		
		CompanyOptions co = new CompanyOptions();//Add by Poly Li on 2004-6-7 13:38
//		String company = (String)session.getAttribute("company");//End by Poly Li

//----------- Modify by Beyes Xia for log 1304 7/2/2004 9:36 AM----------------------------		
		StaffOptions staffOption = new StaffOptions("activation");
//----------- End modify by Beyes Xia ----------------------------------------		
		String str_staffName = session.getAttribute("s_staff_name")==null?"":(String)session.getAttribute("s_staff_name");
             //   String str_dateFrom = session.getAttribute("s_date_from")==null?"":(String)session.getAttribute("s_date_from");
             //   System.out.println("str_dateFrom"+str_dateFrom);
             //   String str_dateTo = session.getAttribute("s_date_to")==null?"":(String)session.getAttribute("s_date_to");
//                System.out.println("co "+co.getOptions(""));
%>

<script language="JavaScript1.1">
function mySubmit()
{
	if(checkDate(fm.date_from) && checkDate(fm.date_to) && checkFromTO())
	{
		fm.submit();
	}
}
function myReset()
{
	fm.staff_name.options[0].selected = true;
	fm.project_name.options[0].selected = true;
	fm.job_name.options[0].selected = true;
	fm.date_from.value = "";
	fm.date_to.value = "";
}
function tss_calendar_from()
{
	var today = new Date();
	show_calendar('fm.date_from', today.getMonth(), today.getYear(), 'YYYY-MM-DD');
}
function tss_calendar_to()
{
	var today = new Date();
	show_calendar('fm.date_to', today.getMonth(), today.getYear(), 'YYYY-MM-DD');
}
function checkFromTO()
{
	if(fm.date_from.value.length!=0 && fm.date_to.value.length!=0 && fm.date_from.value>fm.date_to.value)
	{
		alert("Date From must be earlier than Date To");
		return false;
	}
	return true;
}
function checkDate(object) 
{
	var obj=object;
	var d = obj.value;
     if(d.length !=10)
     {
    		alert("Please input correct date with format as YYYY-MM-DD.");
    		return false;
     }	
     if(d.length==10)
     {
		if (d.substring(4,5)!="-" || d.substring(7,8)!="-") 
	     {
			alert("Please input correct date with format as YYYY-MM-DD.");
			return false;
		}
	     var day = d.substring(8,10);
	     var month = d.substring(5,7);
	     var year = d.substring(0,4);
	     if (day==null || isNaN(day)) 
	     {
			alert("Please input correct date with format as YYYY-MM-DD.");
			return false;
	     }
	     if (month==null || isNaN(month)) 
	     {
			alert("Please input correct date with format as YYYY-MM-DD.");
			return false;
	     }
	     if (day==null || isNaN(day)) 
	     {
			alert("Please input correct date with format as YYYY-MM-DD.");
			return false;
	     }
	     if (day < 1 || day > 31)
	     {
			alert("Please input correct date with format as YYYY-MM-DD.");
			return false;
	     }
	     if (month < 1 || month > 12) 
	     {
			alert("Please input correct date with format as YYYY-MM-DD.");
			return false;
	     }
	     if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	     {
			alert("Please input correct date with format as YYYY-MM-DD.");
			return false;
	     }
	     if (month == 2) 
	     {
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	    		if (day > 29 || (day==29 && !isleap))
	    		{
				alert("Please input correct date with format as YYYY-MM-DD.");
				return false;
	        	}
	      } 
	}
     return true;
}
</script>

<body>
<h2>Weekly Report</h2>
<form id=fm method=post action='<%=contextPath%>/servlet/tss.weeklyexceptionreport.WeeklyException' >
<table cols=4 >
<!--Add by Poly Li on 2004-6-7 13:36  -->
	<tr>
		<td nowrap><b>Cost Center:</b></td>
		<td>
			<select name='cost_center' Style="width=140;">
				<%= co.getOptions("") %>
			</select>
		</td>
	</tr>
<!-- End add by Poly Li -->

<!--Modified by Mike. 2004-01-13. -->
<tr>
	<td><b>Staff Name: </b></td>
	<td>
		<select name=staff_name Style="width=140;">
			<%=staffOption.getOptions(str_staffName,false)%>
          </select>
	</td>
</tr>
<tr>
  <td width='20%'><b>Date Range:</b></td>
  <td >From :&nbsp;
  <input type=text name='date_from'  maxlength=10  ALIGN='LEFT' onBlur='checkDate(this)'>
      <input type=button name=but_cal onClick="tss_calendar_from();" value='...'>(YYYY-MM-DD)*</td>
</tr>
<tr>
<br>
  <td>&nbsp;&nbsp;</td>
  <td >To :&nbsp;&nbsp;
  &nbsp;&nbsp;&nbsp;<input type=text name='date_to'  maxlength=10  ALIGN='LEFT' onBlur='checkDate(this)'>
      <input type=button name=but_cal1 onClick="tss_calendar_to();" value='...'>(YYYY-MM-DD)*</td>
</tr>
<!--End modified SQL by Mike. 2004-01-13. -->

</table>
<br>
<hr>
<p>
  <!--Modified SQL by Mike. 2004-01-13.  -->
  <INPUT type=button value='Export' onclick='mySubmit()'>
  <INPUT type=reset  value='Cancel' onclick='myReset()'>
</p>
</form>
<%  }catch(Exception e) {
	out.println(e.toString());
}%>
<%@ include file="../tssfooter.jsp" %>
</body>
</html>

